<!DOCTYPE html>
<html>
<head>
    <title>SEO管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <#include "../../../include/resources.html">
        <script type="text/javascript">
            $.canEdit = true;
        </script>
        <script type="text/javascript">
            $.canDelete = true;
        </script>
        <script type="text/javascript">
            $.canAdd = false;
        </script>
        <script type="text/javascript">
            $.canGrant = true;
        </script>
        <script type="text/javascript">
            var dataGrid;
            var winWidth =  480;
            var winHeight = 360;
            var addTitle = "添加";
            var addUrl =  "/modules/system/sconfig/SEOAddPage.html";
            var editTitle = "编辑";
            var editUrl =  "/modules/system/sconfig/SEOEditPage.html";
            var cleanUrl = "/modules/system/sconfig/clean.html";//清理缓存
            var addWinParmeters = "'{0}','"+addTitle+"',"+winWidth+","+winHeight+",'"+addUrl+"'";

            $(function() {
                var editIndex = undefined;
                dataGrid = $('#dataGrid').datagrid({
                    url : 'sconfigList.html?type=6',
                    fit : true,
                    fitColumns : true,
                    border : false,
                    pagination : true,
                    idField : 'id',
                    pageSize : pageSize,
                    pageNums :1,
                    pageList : pageList,
                    sortName : 'id',
                    sortOrder : 'asc',
                    checkOnSelect : false,
                    selectOnCheck : false,
                    nowrap : false,
                    singleSelect:true,
                    columns : [ [
                        { field: 'id', title: '编号', width: 50, checkbox : false},
                        { field: 'nid', title: '标识', width: 150, sortable:false},
                        { field: 'name', title: '名称', width: 150, sortable:false},
                        { field: 'value', title: '值', width: 220, sortable:false},
                        { field: 'type', title: '类型', width: 80, sortable:false,
                            formatter:function(value, row, index){
                                if(value == 6){
                                    return "SEO优化";
                                }else {
                                    return "类型异常";
                                }
                            }
                        },
                        { field: 'status', title: '状态', width: 50, sortable:false,
                            formatter:function(value, row, index){
                                if(value == 1){
                                    return "启用";
                                } else if(value == 0){
                                    return "禁用";
                                }
                            }
                        },
                        {	field : 'action',
                            title : '操作',
                            width :50,
                            fixed:true,
                            formatter : function(value, row, index) {
                                var str = '';
                                str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',editTitle,winWidth,winHeight,editUrl);" title="'+editTitle+'">编辑</a>';
                                return str;
                            }
                        } ] ],
                    toolbar : '#toolbar',
                    onLoadSuccess : function() {
                        $('#searchForm table').show();
                        parent.$.messager.progress('close');
                    },
                    onRowContextMenu : function(e, rowIndex, rowData) {
                        e.preventDefault();
                        $(this).datagrid('unselectAll').datagrid('uncheckAll');
                        $(this).datagrid('selectRow', rowIndex);
                        $('#menu').menu('show', {
                            left : e.pageX,
                            top : e.pageY
                        });
                    },
                    onBeforeEdit:function(index,row){
                        row.editing=true;
                        $('#dataGrid').datagrid('refreshRow', index);
                    },
                    onAfterEdit:function(index,row){
                        row.editing=false;
                        $('#dataGrid').datagrid('refreshRow', index);
                    },
                    onDblClickRow : function(rowIndex, rowData){
                        if(editIndex == undefined){
                            $(this).datagrid('beginEdit', rowIndex);
                            editIndex = rowIndex;
                        }else{
                            $(this).datagrid('endEdit', rowIndex);
                        }
                    },
                    onAfterEdit : function(rowIndex, rowData, changes){
                        editIndex = undefined;
                    }
                });
            });

            function getIndexAfterDel(){
                var selected = $('#dataGrid').datagrid('getSelected');
                var index = $('#dataGrid').datagrid('getRowIndex', selected);
                return index;
            }
            function saverow(index,obj){
                var tmpIndex = getIndexAfterDel();
                $('#dataGrid').datagrid('endEdit', index);
                var node = $('#dataGrid').datagrid('getSelected');
                var json = {};
                json.id = node.id;
                json.nid = node.nid;
                json.name = node.name;
                json.value = node.value;
                json.status = node.status;
                $.ajax({
                    url:'/modules/system/sconfig/sconfigEdit.html?randomTime=' + (new Date()).getTime(),
                    type : 'post',
                    data : json,
                    dataType :'json',
                    timeout : 60000,
                    success : function(data, textStatus, jqXHR) {
                        if (data.result){
                            $.messager.alert('提示', '保存成功！', function() {
                                $('#dataGrid').datagrid('reload');
                            });
                        }else{
                            $.messager.alert('提示', '保存失败！');
                        }

                    }
                });
            }
        </script>
</head>
<body style="padding:0 20px;" >
<div class="easyui-layout" data-options="fit : true,border : false">
    <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        <div class="sLeft">
            <form id="searchForm">
                <input type="hidden" name="type" value="6" />
                <input type="text"  name="searchName" class="sInput"  placeholder="输入标识/名称进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
                <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
            </form>
        </div>
        <div class="sRight">
            <a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>添加</a>
            <a onclick="$.fn.formOptions.btnSubFun(clean_cache,cleanUrl,'','')" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe603;</i>清理前台缓存</a>
        </div>
        <form id="showAdw">
            <ul class="showAdw" style="display:none;">
                <a href="javascript:void(0);"><i class="iconfont closeWin">&#xe63a;</i></a>
                <li><span>标识</span><input type="text" name="nid" autocomplete="off"/></li>
                <li><span>名称</span><input type="text" name="name" autocomplete="off"/></li>
                <li><span>状态</span><select name="status" class="type">
                    <option value="99" selected="selected">全部</option>
                    <option value="1">启用</option>
                    <option value="0">禁用</option>
                </select></li>
                <li><span>&nbsp;</span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
            </ul>
        </form>
    </div>
    <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
        <table id="dataGrid"></table>
    </div>
</div>
<!-- 清理缓存 -->
<form id="clean_cache"></form>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>
